const common = {
  namespaced: true,
  state: {
    my: {
      course: [],
      activity: [],
      camp:[],
      shop:[]
    }
  },
  mutations: {},
  actions: {
    MyCourseOrActivityList(context, param) {
      // 我的课程或者活动 列表
      global.POST(global.api.MyCourseOrActivityList, {
        Type: param.Type,
        Page: param.deploy.Page,
        Rows: param.deploy.Rows,
      }).then(res => {
        if (param.clear) {
          if (param.Type == 0)
            context.state.my.activity = res._SignUpList
          else
            context.state.my.course = res._SignUpList
        } else {
          if (param.Type == 0)
            context.state.my.activity = context.state.my.activity.concat(res._SignUpList)
          else
            context.state.my.course = context.state.my.course.concat(res._SignUpList)
        }
        if (param.ref != undefined){
          if (res._SignUpList.length < param.deploy.Rows) {
            param.ref.finishInfinite(true)
          }else{
            param.ref.finishPullToRefresh()
            if (param.pageAdd != undefined)
              param.pageAdd()
          }
        }
        if (param.success != undefined)
          param.success()
      })
    },
    MyCampList(context, param) {
      // 我的营地
      global.POST(global.api.MyCampList, {
        Page: param.deploy.Page,
        Rows: param.deploy.Rows,
      }).then(res => {
        if (param.deploy.Page == 1) {
            context.state.my.camp = res._CampSignUpList
        } else {
            context.state.my.camp = context.state.my.camp.concat(res._CampSignUpList)
        }
        if (param.ref != undefined){
          if (res._CampSignUpList.length < param.deploy.Rows) {
            param.ref.finishInfinite(true)
          }else{
            param.ref.finishPullToRefresh()
            if (param.pageAdd != undefined)
              param.pageAdd()
          }
        }
        if (param.success != undefined)
          param.success()
      })
    },
    MyGoodsList(context, param) {
      // 我的商品
      global.POST(global.api.MyGoodsList, {
        Page: param.deploy.Page,
        Rows: param.deploy.Rows,
      }).then(res => {
        if (param.deploy.Page == 1) {
            context.state.my.shop = res._ConsumptionList
        } else {
            context.state.my.shop = context.state.my.shop.concat(res._ConsumptionList)
        }
        if (param.ref != undefined){
          if (res._ConsumptionList.length < param.deploy.Rows) {
            param.ref.finishInfinite(true)
          }else{
            param.ref.finishPullToRefresh()
            if (param.pageAdd != undefined)
              param.pageAdd()
          }
        }
        if (param.success != undefined)
          param.success()
      })
    },
  },
  getters: {}
}
export default common